/**
 * Copyright (C) 2013-2014 the original author or authors.
 */
package com.foreveross.bsl.mam.model.application.impl;

import javax.inject.Named;

import com.foreveross.bsl.common.utils.bean.BeanHelper;
import com.foreveross.bsl.mam.model.application.AttachmentApplication;
import com.foreveross.bsl.mam.model.application.vo.AttachmentVO;
import com.foreveross.bsl.mam.model.attachment.domain.Attachment;

/**
 * @description
 * 
 * @author rening
 * @version v1.0
 * 
 * @2013-6-7
 * 
 */
@Named("attachmentApplication")
public class AttachmentApplicationImpl implements AttachmentApplication {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.foreveross.bsl.system.application.DatabaseInfoApplication#saveEntity
	 * (com.foreveross.bsl.system.application.vo.DatabaseInfoVO)
	 */
	@Override
	public AttachmentVO saveEntity(AttachmentVO entity) {
		Attachment attachment = new Attachment();
		BeanHelper.copyProperties(attachment, entity);
		attachment.save();
		entity.setId(attachment.getId());
		return entity;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.foreveross.bsl.system.application.DatabaseInfoApplication#getEntity
	 * (java.lang.String)
	 */
	@Override
	public AttachmentVO getEntity(String id) {
		AttachmentVO vo = new AttachmentVO();
		Attachment user = new Attachment();
		user = (Attachment) user.findOne(id);
		BeanHelper.copyProperties(vo, user);
		return vo;
	}

	@Override
	public void deleteEntity(String id) {
		// TODO Auto-generated method stub
		Attachment att = new Attachment();
		att.delete(id);
	}

}
